package com.mmsj;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        // 数据库
        SQLiteDatabase liteDatabase = openOrCreateDatabase("android_database.db", Context.MODE_PRIVATE, null);
        Log.d("MainActivity", "数据库路径：" + liteDatabase.getPath());
        // 创建学生表
        String sql = "CREATE TABLE IF NOT EXISTS student(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER)";
        liteDatabase.execSQL(sql);
        Log.d("MainActivity", "创建学生表" );
        // 插入学生数据
        String insertSql = "INSERT INTO student(name, age) VALUES('张三', 18)";
        liteDatabase.execSQL(insertSql);
        Log.d("MainActivity", "插入学生数据" );


    }
}